Skip to content

Report client usage in the User-Agent header, not source - #6

Merged
jvmvik merged 3 commits into
prepare-1.2.0from
user-agent
Dec 1, 2026
Merged

jvmvik merged 3 commits into
prepare-1.2.0from
user-agent

Conversation

@jvmvik

@jvmvik jvmvik commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Implements serpapi/SerpApi#11027 for serpapi-zig, following serpapi-ruby PR #50.

Changes

  • Every request (GET search and Image API POST) now sends User-Agent: serpapi-zig/<ver> zig/<zig ver> (<os>; <arch>), e.g. serpapi-zig/1.2.0 zig/0.16.0 (macos; aarch64). Previously Zig's default zig/0.16.0 (std.http) was sent.
  • The client no longer appends source=serpapi-zig:<ver>. This also fixes a duplicate source when the caller passed their own (same bug as Go/.NET/C++).
  • The image upload form now sends only api_key + the image.
  • serpapi.user_agent is exported.
  • README and CHANGELOG updated: ships as part of 1.2.0 (no version bump).

OS/arch use Zig's names (macos, x86_64) and are comptime values of the build target.

Testing

  • zig build lint: pass
  • zig build test: 45/45 (3 new, including an offline capture test asserting the header on GET and POST)
  • zig build itest: 23/23
  • zig build oobt, doc, demos: pass
  • Cross-builds for x86_64-linux, x86_64-windows, aarch64-linux, wasm32-wasi: compile

serpapi.com does not echo the User-Agent or source, so the header is verified offline only; live tests confirm the backend accepts it.

Open questions

  • SPEC F8/F8b should be updated to retire source and describe the runtime/platform suffix.

Stacked on #5 (prepare-1.2.0).

🤖 Generated with Claude Code

jvmvik and others added 3 commits November 30, 2026 17:56
AI: Claude Opus 5.5 · effort high · serpapi-sdk-developer: ported serpapi-ruby PR #50 (SerpApi#11027) to Zig, ran lint, offline + live suites, oobt, cov, demos and cross builds

Every request now sends
`User-Agent: serpapi-zig/<version> zig/<zig version> (<os>; <arch>)`,
e.g. `serpapi-zig/1.2.0 zig/0.16.0 (macos; aarch64)`, set once in
fetchStatus so GET and the Image API POST share it. It replaces std.http's
default `zig/0.16.0 (std.http)` and is a comptime constant exported as
`serpapi.user_agent`.

The client no longer adds `source=serpapi-zig:<version>` to URLs or the
image form, matching serpapi-ruby. This also fixes a constructor `.source`
being sent next to the library's own (two `source` values).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the Unreleased CHANGELOG and README entries into the 1.2.0 section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvmvik
jvmvik merged commit 4107998 into prepare-1.2.0 Dec 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant